<script setup>
	import { computed } from 'vue'
	import { useStore } from 'vuex'
	import { useRoute } from 'vue-router'
	const store = useStore()
	const route = useRoute()
	
	// 面包屑
	const crumbs = computed(() => {
		let result = []
		let haveRoutes = store.state.app.haveRoutes
		let paths = route.fullPath.split('/').splice(2)
		paths.forEach(item => {
			let findRes = haveRoutes.find(it => it.name == item)
			if (findRes) {
				result.push({
					title: findRes.meta.title,
					to: findRes.path
				})
			}
		})
		// console.log(paths, result)
		return result
	})
</script>

<template>
	<el-breadcrumb separator-icon="ArrowRight">
	    <el-breadcrumb-item :to="{ path: '/main' }">首页</el-breadcrumb-item>
	    <el-breadcrumb-item
			:to="item.to"
			v-for="(item, index) in crumbs"
			:key="index"
		>
			{{ item.title }}
		</el-breadcrumb-item>
	</el-breadcrumb>
</template>

<style scoped lang="less">
</style>
